<template>
  <div>
      <van-field label="输入用户名" v-model="data.acc"/>
      <van-field label="输入密码" type="password" v-model="data.password"/>
      <van-button @click="login">登录</van-button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'login',
    data(){
        return{
            data:{
                acc:'',
                password:''
            }
        }
    },
    methods:{
        login(){
            axios.post('/login',this.data).then(res=>{
                console.log(res);
                if(res.data.code==200){
                    localStorage.setItem('username',res.data.username)
                    localStorage.setItem('uid',res.data.uid)
                    localStorage.setItem('page_def',JSON.stringify(res.data.page_def))
                    localStorage.setItem('token',res.data.token)
                }
            })
        }
    }
}
</script>

<style>

</style>